package com.example.rabbitboot;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author cxx
 * @create 2020-02-21 10:01
 **/
@RequestMapping
@RestController
public class RabbitProduce {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @GetMapping("produce/{msg}")
    public String produce(@PathVariable String msg){
        rabbitTemplate.convertAndSend ("direct","mykey",msg);
        return msg;
    }

}
